﻿<!DOCTYPE html>
<html>

<head id="Head1" runat="server">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>问题快反看板</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <link rel="Shortcut Icon" href="../images/aecc.ico" type="image/x-icon" />
  <link rel="stylesheet" href="../StaticFiles/layui/dist/css/layui.css" />
  <link rel="stylesheet" href="../StaticFiles/layui/admin.css" />
  <link rel="stylesheet" href="../styles/pace.css" />
  <script type="text/javascript" src="../Scripts/pace.min.js"></script>
  <script type="text/javascript" src="../Scripts/json2.js"></script>
  <script type="text/javascript" src="../Scripts/jquery-1.11.2.min.js"></script>
  <style type="text/css">
    html {
      background-image: url(../images/bg.jpg);
      background-repeat: no-repeat;
    }

    .layui-card {
      background-color: transparent;
    }

    .layui-card-header {
      color: #fff;
      border: none;
      text-align: center;
      font-size: 20px;
      font-weight: bold;
      letter-spacing: 0.1em;
    }

    .layui-table-cell {
      text-align: center;
      color: #fff;
    }

    .layui-table {
      background-color: transparent !important;
    }

    .layui-table-view {
      margin-top: 0px;
    }

    .layui-table-header {
      background-color: transparent !important;
    }

    /*表格标题*/
    .layui-table-header .layui-table-cell {
      color: #FFF;
      font-size: 24px;
      font-family: '黑体';
      font-weight: bold;
      margin: 0px 0px;
      height: 60px;
      line-height: 60px;
    }

    /*表格单元格*/
    .layui-table-cell {
      color: #FFF;
      font-size: 18px;
      font-family: '微软雅黑';
      margin: 0px 0px;
      height: 60px;
      line-height: 60px;
      font-weight: bold;
    }

    .layui-table tr:hover {
      background-color: transparent !important;
    }

    .layui-table thead tr {
      background-color: transparent !important;
    }

    .layui-laypage a,
    .layui-laypage span {
      color: #fff;
    }

    .layui-laypage .layui-laypage-skip {
      color: #fff;
    }

    .layui-table td,
    .layui-table th,
    .layui-table-col-set,
    .layui-table-fixed-r,
    .layui-table-grid-down,
    .layui-table-header,
    .layui-table-page,
    .layui-table-tips-main,
    .layui-table-tool,
    .layui-table-total,
    .layui-table-view,
    .layui-table[lay-skin=line],
    .layui-table[lay-skin=row] {
      border-color: #808080;
    }

    .layui-table-view .layui-table td,
    .layui-table-view .layui-table th {
      margin: 0;
      padding: 0;
    }
  </style>
</head>

<body>
  <!--[if lt IE 9]>
        <script src="../Scripts/pollyfills/es5-shim.min.js"></script>
        <script src="../Scripts/pollyfills/es5-sham.min.js"></script>
        <script src="../Scripts/pollyfills/html5.js"></script>
        <script src="../Scripts/pollyfills/response.js"></script>
    <![endif]-->
  <div class="layui-row" style="padding: 0px 15px;">
    <div class="layui-col-md3">
      <div>
        <img src="../images/aeec_logo.png" alt="" height="60" />
      </div>
    </div>
    <div class="layui-col-md6" style="height: 60px; line-height: 60px; text-align: center;
            font-family: '黑体'; font-size: 36px; letter-spacing: 0.1em; color: #fff;" id="factoryid">
      问题快反看板
    </div>
    <div class="layui-col-md3" style="height: 60px; line-height: 60px; text-align: right;
            font-size: 16px; font-weight: bold; color: #fff;" id="currentTime">
    </div>
  </div>
  <div class="layui-row layui-col-space5">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-body">
          <table id='test'>
          </table>
        </div>
      </div>
    </div>
  </div>
  <script src="../Scripts/echarts/echarts-5.4.0.min.js"></script>
  <script type="text/javascript" src="../StaticFiles/layui/dist/layui.js"></script>
  <script type="text/javascript">
    $(function () {
      $(".layui-card:last-child").css({ "marginBottom": "0px" });
      function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
      };
      var $factoryid = getUrlParam('factoryid');
      var factoryname = "";

      var uid = layui.url().search.uid; //用户id
      var empInfo = null;
      // 看板刷新时间
      var interval = 5 * 60 * 1000;

      // 页面右上方时钟
      function showTime() {
        var currentTime = new Date();
        var year = currentTime.getFullYear();
        var month = currentTime.getMonth() + 1;
        var date = currentTime.getDate();
        var day = currentTime.getDay();
        var hours = currentTime.getHours();
        var minutes = currentTime.getMinutes();
        var seconds = currentTime.getSeconds();
        var time = document.getElementById("currentTime");
        if (seconds < 10) {
          seconds = "0" + seconds;
        }
        if (minutes < 10) {
          minutes = "0" + minutes;
        }
        time.innerHTML = year + "年" + month + "月" + date + "日   " + hours + " : " + minutes + " : " + seconds;
      };
      setInterval(showTime, 500);

      layui.use(['layer', 'table'], function () {
        var table = layui.table;
        var layer = layui.layer;

        //查询用户信息
        $.ajax({
          type: "POST",
          url: "../handler/report/ZSWorktimeReport.ashx?type=GetFactory",
          dataType: "text",
          cashe: false,
          data: {
            factoryid: $factoryid
          },
          success: function (result) {
            var json = JSON.parse(result);
            factoryname = json[0]["FACTORYNAME"];

            document.title = factoryname + "--问题快反看板";
            $("#factoryid").text(factoryname + "--问题快反看板");
          }
        });

        var col = [[
          { field: 'problemtype', title: '快反问题' },
          { field: 'resworkcentername', title: '责任单位', width: 180 },
          { field: 'fullname', title: '提交人', width: 120 },
          {
            field: 'submitdate', title: '提交时间', width: 220,
            templet: function (d) {
              if (d.submitdate === null) {
                return "";
              } else {
                return d.submitdate.replace('T', ' ');
              }
            }
          },
          { field: 'workcentername', title: '提出工区', width: 180 },
          { field: 'shiftname', title: '班', width: 160 },
          { field: 'teamname', title: '组', width: 160 },
          { field: 'dualmin', title: '等待时间(分钟)' },
          {
            field: 'problemstatus', title: '状态', width: 80,
            templet: function (d) {
              if (d.problemstatus == '已提交') {
                //return '<span style="background-color: rgb(255,0,0);padding:15px;border-radius:5px;">' + '待处理' + '</span>';
                return '<div style="text-align:center;color:red;"><img src="../images/timg.gif" width="30px" style="margin:0 auto;"></div>'
              }
            }
          }
        ]];

        //查询用户信息
        $.ajax({
          type: "POST",
          url: "../handler/report/ZSWorktimeReport.ashx?type=GetEmpInfo",
          dataType: "text",
          cashe: false,
          data: {
            uid: uid
          },
          success: function (result) {
            var json = JSON.parse(result);
            if (json.length == 0) {
              alert("当前用户不存在，请重新登录");
              window.location.href = "http://" + window.location.host + "/Mesreport/login.aspx";
            } else {
              empInfo = json;

              GetProblemFeedBackData();

              //定时刷新
              setInterval(function () {
                GetProblemFeedBackData();
              }, interval);
            }
          }
        });

        //问题快反数据
        function GetProblemFeedBackData() {
          var cols = [];
          if (factoryname === "盘轴制造分厂") {
            cols = [[
              { field: 'problemtype', title: '快反问题' },
              { field: 'resworkcentername', title: '责任单位', width: 180 },
              { field: 'fullname', title: '提交人', width: 120 },
              {
                field: 'submitdate', title: '提交时间', width: 220,
                templet: function (d) {
                  if (d.submitdate === null) {
                    return "";
                  } else {
                    return d.submitdate.replace('T', ' ');
                  }
                }
              },
              { field: 'workcentername', title: '提出工区', width: 180 },
              { field: 'teamname', title: '组', width: 160 },
              { field: 'dualmin', title: '等待时间(分钟)' },
              {
                field: 'problemstatus', title: '状态', width: 80,
                templet: function (d) {
                  if (d.problemstatus == '已提交') {
                    //return '<span style="background-color: rgb(255,0,0);padding:15px;border-radius:5px;">' + '待处理' + '</span>';
                    return '<div style="text-align:center;color:red;"><img src="../images/timg.gif" width="30px" style="margin:0 auto;"></div>'
                  }
                }
              }
            ]];
          } else {
            cols = [[
              { field: 'problemtype', title: '快反问题' },
              { field: 'resworkcentername', title: '责任单位', width: 180 },
              { field: 'fullname', title: '提交人', width: 120 },
              {
                field: 'submitdate', title: '提交时间', width: 220,
                templet: function (d) {
                  if (d.submitdate === null) {
                    return "";
                  } else {
                    return d.submitdate.replace('T', ' ');
                  }
                }
              },
              { field: 'workcentername', title: '提出工区', width: 180 },
              { field: 'shiftname', title: '班', width: 160 },
              { field: 'teamname', title: '组', width: 160 },
              { field: 'dualmin', title: '等待时间(分钟)' },
              {
                field: 'problemstatus', title: '状态', width: 80,
                templet: function (d) {
                  if (d.problemstatus == '已提交') {
                    //return '<span style="background-color: rgb(255,0,0);padding:15px;border-radius:5px;">' + '待处理' + '</span>';
                    return '<div style="text-align:center;color:red;"><img src="../images/timg.gif" width="30px" style="margin:0 auto;"></div>'
                  }
                }
              }
            ]];
          }


          table.render({
            elem: '#test',
            url: "../handler/board/ZSProblemFeedBack.ashx",
            method: 'POST',
            where: {
              type: 'GetData',
              workcenterid: empInfo[0].WORKCENTERID,
              factoryid: $factoryid
            },
            text: {
              none: '暂无相关数据'
            },
            cols: cols,
            done: function (res, curr, count) {
              var that = this.elem.next();
              res.data.forEach(function (item, index) {
                if (index % 2 !== 0) {
                  var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css({ "background": "blue" });
                }
              });
            }
          });

        };
      });
    });
  </script>
</body>

</html>